<template>
	<view class="column-css">
		<view class="row-css view-ceritfi">
			<view>实名状态</view>
			<view
				style="border-radius: 25rpx;background: #4CD964;padding: 5rpx 10rpx; color: #FFFFFF;"
				:style="{ background: certificatInfo.realnameState == 0 ? '#E04B28' : '#4CD964' }"
			>
				{{ certificatInfo.realnameState == 0 ? '未实名' : '已实名' }}
			</view>
		</view>

		<view class="row-css" style="justify-content: space-between;padding: 10rpx 20rpx;">
			<view style="background: #f6f6f6;">证件已上传</view>
			<view style="background: #f6f6f6;">{{ certificatInfo.uploadNum }}/{{ certificatInfo.total }}</view>
		</view>

		<view class="column-css" style="background: #FFFFFF;padding: 10rpx 0;">
			<view class="row-css" style="justify-content: space-between;padding: 0 20rpx;">
				<view>身份证人像面</view>
				<view :style="{ color: cerstauscolor(certificatInfo.idCard1State) }">{{ cerState(certificatInfo.idCard1State) }}</view>
			</view>
			<view class="column-css" style="align-items: center;">
				<image
					style="margin: 20rpx;width: 470rpx;height: 290rpx;"
					mode="aspectFit"
					:src="certificatInfo.idcard1 == '' ? carmeimage : certificatInfo.idcard1"
					@tap="chooseImage(1)"
				></image>
				<view v-if="certificatInfo.idCard1State != 0" style="color: #C0C0C0;">点击图片更新({{ cerState(certificatInfo.idCard1State) }})</view>
				<view v-else style="color: #C0C0C0;">点击相机进行上传({{ cerState(certificatInfo.idCard1State) }})</view>
				<!-- <view style="color: #C0C0C0;padding: 10rpx 0;">点击图片更新证件(已过期)</view>
				<view style="color: #C0C0C0;padding: 10rpx 0;">点击图片上传证件(未上传)</view> -->
			</view>
		</view>

		<view class="column-css" style="background: #FFFFFF;padding: 10rpx 0;margin-top: 10rpx;">
			<view class="row-css" style="justify-content: space-between;padding: 0 20rpx;">
				<view>身份证国徽面</view>
				<view :style="{ color: cerstauscolor(certificatInfo.idCard2State) }">{{ cerState(certificatInfo.idCard2State) }}</view>
			</view>
			<view class="column-css" style="align-items: center;">
				<image
					style="margin: 20rpx;width: 470rpx;height: 290rpx;"
					mode="aspectFit"
					:src="certificatInfo.idcard2 == '' ? carmeimage : certificatInfo.idcard2"
					@tap="chooseImage(2)"
				></image>
				<view v-if="certificatInfo.idCard2State != 0" style="color: #C0C0C0;">点击图片更新({{ cerState(certificatInfo.idCard2State) }})</view>
				<view v-else style="color: #C0C0C0;">点击相机进行上传({{ cerState(certificatInfo.idCard2State) }})</view>
				<!-- <view style="color: #C0C0C0;padding: 10rpx 0;">点击图片更新证件(已过期)</view>
				<view style="color: #C0C0C0;padding: 10rpx 0;">点击图片上传证件(未上传)</view> -->
			</view>
		</view>

		<view class="column-css" style="background: #FFFFFF;padding: 10rpx 0;margin-top: 10rpx;">
			<view class="row-css" style="justify-content: space-between;padding: 0 20rpx;">
				<view>驾驶证正页</view>
				<view :style="{ color: cerstauscolor(certificatInfo.driverLicenseState) }">{{ cerState(certificatInfo.driverLicenseState) }}</view>
			</view>
			<view class="column-css" style="align-items: center;">
				<image
					style="margin: 20rpx;width: 470rpx;height: 290rpx;"
					mode="aspectFit"
					:src="certificatInfo.driverLicense == '' ? carmeimage : certificatInfo.driverLicense"
					@tap="chooseImage(3)"
				></image>
				<view v-if="certificatInfo.driverLicenseState != 0" style="color: #C0C0C0;">点击图片更新({{ cerState(certificatInfo.driverLicenseState) }})</view>
				<view v-else style="color: #C0C0C0;">点击相机进行上传({{ cerState(certificatInfo.driverLicenseState) }})</view>
				<!-- <view style="color: #C0C0C0;padding: 10rpx 0;">点击图片更新证件(已过期)</view>
				<view style="color: #C0C0C0;padding: 10rpx 0;">点击图片上传证件(未上传)</view> -->
			</view>
		</view>
		
		<view class="column-css" style="background: #FFFFFF;padding: 10rpx 0;margin-top: 10rpx;">
			<view class="row-css" style="justify-content: space-between;padding: 0 20rpx;">
				<view>驾驶证副页</view>
				<view :style="{ color: cerstauscolor(certificatInfo.drivingLicenseDeputyState) }">{{ cerState(certificatInfo.drivingLicenseDeputyState) }}</view>
			</view>
			<view class="column-css" style="align-items: center;">
				<image
					style="margin: 20rpx;width: 470rpx;height: 290rpx;"
					mode="aspectFit"
					:src="certificatInfo.drivingLicenseDeputy == '' ? carmeimage : certificatInfo.drivingLicenseDeputy"
					@tap="chooseImage(4)"
				></image>
				<view v-if="certificatInfo.drivingLicenseDeputyState != 0" style="color: #C0C0C0;">点击图片更新({{ cerState(certificatInfo.drivingLicenseDeputyState) }})</view>
				<view v-else style="color: #C0C0C0;">点击相机进行上传({{ cerState(certificatInfo.drivingLicenseDeputyState) }})</view>
				<!-- <view style="color: #C0C0C0;padding: 10rpx 0;">点击图片更新证件(已过期)</view>
				<view style="color: #C0C0C0;padding: 10rpx 0;">点击图片上传证件(未上传)</view> -->
			</view>
		</view>

		<view class="column-css" style="background: #FFFFFF;padding: 10rpx 0;margin-top: 10rpx;">
			<view class="row-css" style="justify-content: space-between;padding: 0 20rpx;">
				<view>从业资格证正页</view>
				<view :style="{ color: cerstauscolor(certificatInfo.tqcState) }">{{ cerState(certificatInfo.tqcState) }}</view>
			</view>
			<view class="column-css" style="align-items: center;">
				<image
					style="margin: 20rpx;width: 470rpx;height: 290rpx;"
					mode="aspectFit"
					:src="certificatInfo.tqc == '' ? carmeimage : certificatInfo.tqc"
					@tap="chooseImage(5)"
				></image>
				<view v-if="certificatInfo.tqcState != 0" style="color: #C0C0C0;">点击图片更新({{ cerState(certificatInfo.tqcState) }})</view>
				<view v-else style="color: #C0C0C0;">点击相机进行上传({{ cerState(certificatInfo.tqcState) }})</view>
				<!-- <view style="color: #C0C0C0;padding: 10rpx 0;">点击图片更新证件(已过期)</view>
				<view style="color: #C0C0C0;padding: 10rpx 0;">点击图片上传证件(未上传)</view> -->
			</view>
		</view>
		<view class="column-css" style="background: #FFFFFF;padding: 10rpx 0;margin-top: 10rpx;display: none;">
			<view class="row-css" style="justify-content: space-between;padding: 0 20rpx;">
				<view>从业资格证副页</view>
				<view :style="{ color: cerstauscolor(certificatInfo.tqcDeputyState) }">{{ cerState(certificatInfo.tqcDeputyState) }}</view>
			</view>
			<view class="column-css" style="align-items: center;">
				<image
					style="margin: 20rpx;width: 470rpx;height: 290rpx;"
					mode="aspectFit"
					:src="certificatInfo.tqcDeputy == '' ? carmeimage : certificatInfo.tqcDeputy"
					@tap="chooseImage(6)"
				></image>
				<view v-if="certificatInfo.tqcDeputyState != 0" style="color: #C0C0C0;">点击图片更新({{ cerState(certificatInfo.tqcDeputyState) }})</view>
				<view v-else style="color: #C0C0C0;">点击相机进行上传({{ cerState(certificatInfo.tqcDeputyState) }})</view>
				<!-- <view style="color: #C0C0C0;padding: 10rpx 0;">点击图片更新证件(已过期)</view>
				<view style="color: #C0C0C0;padding: 10rpx 0;">点击图片上传证件(未上传)</view> -->
			</view>
		</view>
		
		<uni-popup ref="popup" type="bottom" mask-background-color="rgba(0,0,0,0.8)">
			<view class="popup-wrap">
				<view class="popup-describe">
					<image v-if="index == 1" src="../../static/icon_example_idcard01.png" mode="aspectFit"></image>
					<image v-if="index == 2" src="../../static/icon_example_idcard02.png" mode="aspectFit"></image>
					<image v-if="index == 3" src="../../static/icon_example_driver01.png" mode="aspectFit"></image>
					<image v-if="index == 4" src="../../static/icon_example_driver02.png" mode="aspectFit"></image>
					<image v-if="index == 5" src="../../static/icon_example_bus.png" mode="aspectFit"></image>
					<view>
						<view class="title">{{title}}</view>
						<view class="desc">
							<view>保证证件四角可见，无遮挡，无反光；</view>
							<view>{{desc}}</view>
						</view>
					</view>
				</view>
				<view class="popup-box">
					<view @click="onCamera(0)">拍照</view>
					<view @click="onCamera(1)">从相册选择</view>
				</view>
				<view class="popup-cancel" @click="onCancel">取消</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
export default {
	data() {
		return {
			driverId: '',
			certificatInfo: {},
			carmeimage: '../../static/icon_carmer.png',
			index: null,
			title: '',
			desc: ''
		};
	},
	onLoad(options) {
		this.driverId = uni.getStorageSync(this.DATA_KEY.userInfo).driverId;
		this.getCertificat();
	},
	methods: {
		getCertificat() {
			this.wxRequest({
				url: `${this.API}/driverService/driverCertificat`,
				method: 'POST',
				data: {
					driverId: this.driverId
				},
				title: '加载中...',
				success: res => {
					console.log('dd============', res);
					this.certificatInfo = res.data.data;
				}
			});
		},
		cerState: function(staus) {
			let stats = '';
			switch (staus) {
				case '0':
					stats = '未上传';
					break;
				case '1':
					stats = '已上传';
					break;
				case '2':
					stats = '已过期';
					break;
			}
			return stats;
		},
		cerstauscolor: function(staus) {
			let color = '#E04B28';
			if (staus == '1') {
				color = '#4CD964';
			}
			return color;
		},
		onCancel(){
			this.$refs.popup.close()
		},
		chooseImage: async function(index) {
			this.index = index
			this.$refs.popup.open()
			if(this.index == 1) {
				this.title = '请上传身份证人像面照片'
				this.desc = '姓名、身份照号码等信息清晰，无涂改'
			} else if(this.index == 2) {
				this.title = '请上传身份证国徽面照片'
				this.desc = '发证机关、有效期等信息清晰，无涂改'
			} else if(this.index == 3) {
				this.title = '请上传本人驾驶证正页照片'
				this.desc = '同时支持电子驾驶证正页照片，文字清晰可辩'
			} else if(this.index == 4) {
				this.title = '请上传本人驾驶证副页照片'
				this.desc = '同时支持电子驾驶证副页照片，文字清晰可辩'
			} else if(this.index == 5) {
				this.title = '请上传本人从业资格证照片'
				this.desc = '姓名、证件号码、有效期等信息清晰，无涂改'
			}
			return
			// TODO 选择相机或相册时 需要弹出actionsheet，目前无法获得是相机还是相册，在失败回调中处理
			uni.chooseImage({
				count: 1,
				sizeType:'compressed',
				success: res => {
					let resSize = res.tempFiles[0].size;
					if (resSize > 10485760) {
						uni.showToast({
							title: '上传的图片大小不超过10M,请重新上传！',
							icon: 'none',
							duration: 2000,
							mask: true
						});
						return;
					}
					uni.showLoading({
						title: '上传中'
					});
					if (index == 1) {
						uni.uploadFile({
							url: `${this.API}/driverService/uploadIdcard1Change`,
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '2',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('身份证正面更新: ', JSON.parse(res.data));
								let respost = JSON.parse(res.data);
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					} else if (index == 2) {
						uni.uploadFile({
							url: `${this.API}/driverService/uploadIdcard2Change`, //仅为示例，非真实的接口地址
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '3',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('身份证国徽面: ', JSON.parse(res.data));
								let respost = JSON.parse(res.data);
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					} else if (index == 3) {
						uni.uploadFile({
							url: `${this.API}/driverService/uploadDriverLicenseChange`, //仅为示例，非真实的接口地址
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '4',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('驾驶证正页: ', JSON.parse(res.data));
								let respost = JSON.parse(res.data);
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					}else if (index == 4) {
						uni.uploadFile({
							url: `${this.API}/driverService/upload_driving_deputy`, //仅为示例，非真实的接口地址
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '4',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('驾驶证正面: ', JSON.parse(res.data));
								let respost = JSON.parse(res.data);
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					} else if (index == 5) {
						uni.uploadFile({
							url: `${this.API}/driverService/uploadTqcChange`,
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '2',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('tqc: ', JSON.parse(res.data));
								// let respost = JSON.parse(res.data).imgurl;
								let respost = JSON.parse(res.data);
								console.log(respost)
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					} else if (index == 6) {
						uni.uploadFile({
							url: `${this.API}/driverService/uploadTqcChangeDeputy`,
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '2',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('tqc: ', JSON.parse(res.data));
								let respost = JSON.parse(res.data);
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					}
				}
				// fail: err => {
				// 	uni.getSetting({
				// 		success: res => {
				// 			let authStatus = false;
				// 			switch (this.sourceTypeIndex) {
				// 				case 0:
				// 					authStatus = res.authSetting['scope.camera'];
				// 					break;
				// 				case 1:
				// 					authStatus = res.authSetting['scope.album'];
				// 					break;
				// 				case 2:
				// 					authStatus = res.authSetting['scope.album'] && res.authSetting['scope.camera'];
				// 					break;
				// 				default:
				// 					break;
				// 			}
				// 			if (!authStatus) {
				// 				uni.showModal({
				// 					title: '授权失败',
				// 					content: '认证需要从您的相机或相册获取图片，请在设置界面打开相关权限',
				// 					success: res => {
				// 						if (res.confirm) {
				// 							uni.openSetting();
				// 						}
				// 					}
				// 				});
				// 			}
				// 		}
				// 	});
				// }
			});
		},
		onCamera(num) {
			let sourceType
			num === 0 ? sourceType = ['camera'] : sourceType = ['album'] 
			let index = this.index
			this.$refs.popup.close()
			uni.chooseImage({
				count: 1,
				sourceType: sourceType,
				sizeType: 'compressed',
				success: res => {
					let resSize = res.tempFiles[0].size;
					if (resSize > 10485760) {
						uni.showToast({
							title: '上传的图片大小不超过10M,请重新上传！',
							icon: 'none',
							duration: 2000,
							mask: true
						});
						return;
					}
					uni.showLoading({
						title: '上传中'
					});
					if (index == 1) {
						uni.uploadFile({
							url: `${this.API}/driverService/uploadIdcard1Change`,
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '2',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('身份证正面更新: ', JSON.parse(res.data));
								let respost = JSON.parse(res.data);
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					} else if (index == 2) {
						uni.uploadFile({
							url: `${this.API}/driverService/uploadIdcard2Change`, //仅为示例，非真实的接口地址
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '3',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('身份证国徽面: ', JSON.parse(res.data));
								let respost = JSON.parse(res.data);
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					} else if (index == 3) {
						uni.uploadFile({
							url: `${this.API}/driverService/uploadDriverLicenseChange`, //仅为示例，非真实的接口地址
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '4',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('驾驶证正页: ', JSON.parse(res.data));
								let respost = JSON.parse(res.data);
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					}else if (index == 4) {
						uni.uploadFile({
							url: `${this.API}/driverService/upload_driving_deputy`, //仅为示例，非真实的接口地址
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '4',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('驾驶证正面: ', JSON.parse(res.data));
								let respost = JSON.parse(res.data);
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					} else if (index == 5) {
						uni.uploadFile({
							url: `${this.API}/driverService/uploadTqcChange`,
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '2',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('tqc: ', JSON.parse(res.data));
								// let respost = JSON.parse(res.data).imgurl;
								let respost = JSON.parse(res.data);
								console.log(respost)
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					} else if (index == 6) {
						uni.uploadFile({
							url: `${this.API}/driverService/uploadTqcChangeDeputy`,
							fileType: 'image',
							name: 'file',
							filePath: res.tempFilePaths[0],
							file: res.tempFiles,
							header: {
								'Content-Type': 'multipart/form-data;boundary=ebf9f03029db4c2799ae16b5428b06bds',
								Authorization: uni.getStorageSync(this.DATA_KEY.token)
							},
							formData: {
								fileType: '2',
								fileId: Math.floor(Math.random() * 1259),
								ocrOrNot: '1',
								driverId: this.driverId
							},
							success: res => {
								console.log('tqc: ', JSON.parse(res.data));
								let respost = JSON.parse(res.data);
								uni.hideLoading();
								if (respost.code == 0) {
									this.getCertificat();
								} else {
									uni.showToast({
										title: respost.msg,
										icon: 'none'
									});
								}
							},
							fail: error => {
								uni.showToast({
									title: '文件上传失败',
									icon: 'none'
								});
							}
						});
					}
				},
				fail: (err) => {
					console.log(err)
				}
			})
		}
		
	}
};
</script>

<style lang="scss">
	.popup-wrap{
		// padding: 0 24rpx calc(24rpx + env(safe-area-inset-bottom));
		padding: 0 24rpx calc(24rpx);
		color: #007aff;
		text-align: center;
		background: transparent;
		.popup-describe{
			color: #fff;
			position: absolute;
			top: -55vh;
			left: 50%;
			transform: translate(-50%, 0);
			.title{
				margin: 24rpx 0;
				font-size: 36rpx;
			}
			.desc{
				font-size: 24rpx;
			}
		}
		.popup-box{
			background: #fff;
			margin-bottom: 24rpx;
			border-radius: 8rpx;
			view{
				padding: 24rpx 0;
				&:first-child{
					border-bottom: 1rpx solid #f9f9f9;
				}
			}
		}
		.popup-cancel{
			background: #fff;
			padding: 24rpx 0;
			border-radius: 8rpx;
		}
	}
.row-css {
	display: flex;
	flex-direction: row;
}

.column-css {
	display: flex;
	flex-direction: column;
}

.view-ceritfi {
	background: #ffffff;
	margin-top: 1rpx;
	padding: 20rpx;
	justify-content: space-between;
}

.view-centen-text {
}

.view-cent {
}
</style>
